/** 
* Trigger Name: OORTelesalesMCAndQuotaDateUnique
* Author: Accenture IDC 
* Date: 30-March-2012
* Requirement/Project Name: SFA OOR Telesales
* Requirement/Project Description: Do not allow duplicate values for MC and Quota Date Field.
**/
trigger OORTelesalesMCAndQuotaDateUnique on QuotaManagement__c (before update,before insert){
    
     List<QuotaManagement__c> quotaManList = Trigger.new;
     Set <String>  mapKey = null;  
     //Map variable for storing UniqueKey value and Quota Object   
     Map<String, QuotaManagement__c> quotaManMap = new Map<String, QuotaManagement__c>();
     
     //QuotaManagement Object for displaying Error Message.
     QuotaManagement__c quoManObj = null;
     
     //Loop for featching the Duplicate values from DB.
     for(QuotaManagement__c quotaManObj:  quotaManList)
     {
        quotaManMap.put(quotaManObj.UniqueKey__c, quotaManObj);
     //   system.debug('Quota Man Obj with Unique Key' + quotaManObj.UniqueKey__c );
     }
     mapKey = quotaManMap.keySet();
     //Loop for disaplaying Error Message for the duplicate values found.
     for(QuotaManagement__c quotaObj:[SELECT UniqueKey__c from QuotaManagement__c WHERE UniqueKey__c IN: quotaManMap.keySet()])
     {
         if (mapKey.contains(quotaObj.UniqueKey__c))
         {
             quoManObj = quotaManMap.get(quotaObj.UniqueKey__c);
             quoManObj.addError(OORTelesalesTextConstant.PREVENT_DUPLICATE_MC_QUOTA_DATE);
         }
     }
}